<?php echo $this->Form->create('Paginate', array('id' => 'paginate', 'url' => $this->request->here(false), 'type' => 'post', 'inputDefaults' => array('label' => false))); ?>                           

<div id="content-header">
<h1><?php echo __d('system','Content Management');?></h1>
</div>
<div id="breadcrumb">
    <a href="<?php echo $this->Html->url('/admin/')?>" title="Go to Home" class="tip-bottom"><i class="icon-home"></i> <?php echo __d('system','Home');?></a>
    <a href="#" class="current"><?php echo __d('system','List Contents');?></a>
</div>
<div class="container-fluid">
<div class="row-fluid">
    <div class="span12">
    <?php     echo $this->element('toolbar');?>    
    <?php echo $this->Session->flash(); ?>                             
        <div class="widget-box">
            <div class="widget-title">
                <span class="icon">
                    <i class="icon-th"></i>
                </span>
                <h5><?php echo __d('system','List of content');?></h5>
            </div>
            <div class="widget-content widget-content-two">
                <div class="wd-group-user">
                    <div class="wd-email">
                        <div class="wd-input">
                            <label><span> <?php echo __d('system','Choose Group');?>:</span></label>
                                 <?php echo $this->Form->input('groupUser',array(
                                    'type'=>'select',
                                    'div'=>false,
                                    'label'=>false,
                                    'options'=>$groupUser
                                 ));
                                 ?>
                        </div>
                     </div>                     
                     <label><span><?php echo __d('system','Danh sách email');?>:</span></label>
                     <?php if(!empty($list_email)):?>
                         <ul class="list-user-email">
                                <li class="check_all">                            
                                    <input type="checkbox" value="" class="input-chk-all"><?php echo __d('system','Check All');?>                                         
                                </li> 
                                <?php foreach($list_email as $k=>$v):?>                       
                                    <li class="mail_<?php echo $v['Node']['id'];?>">
                                        <input type="checkbox" onclick="add_mail_user('<?php echo $v['Node']['field_email'];?>','<?php echo $v['Node']['id'];?>');" value="<?php echo $v['Node']['field_email'];?>" class="_lst_email_<?php echo $v['Node']['id'];?>"> <?php echo $v['Node']['field_email'];?>                                        
                                    </li>                                
                                <?php endforeach;?>
                         </ul>
                     <?php else:?>
                         <?php echo __d('system','Không có email nào !!!');?>
                     <?php endif;?>                           
                </div>
                <br/>
                <div class="wd-group-checked">
                    <label><span><?php echo __d('system','List Checked');?></span></label>                               
                    <ul class="list-email-checked"></ul>
                </div>
            </div>
        </div>
    </div>    
</div>
<script >
    $('document').ready(function() {            
            $('.check_all .input-chk-all').live('click',function(){                
                    if($(this).is(':checked')){                        
                        myItems = '<?php echo json_encode($list_email);?>';                    
                        var obj = jQuery.parseJSON(myItems);
                        var lenstr = obj.length;
                        for(objs in obj){
                            var _getId = parseInt(obj[objs]['Node']['id']) ;  
                            var _getEmail = String(obj[objs]['Node']['field_email']) ;                          
                            var _email = '';
                            _email += "<li class=mail_"+_getId+">";
                            _email += "<input type=hidden"; 
                            _email += " name=data[Node][email][]";       
                            _email += " value="+_getEmail;
                            _email += " class=_lst_email_"+_getId;
                            _email += "> ";
                            _email += _getEmail;
                            _email += "<a href='#' onclick=_delete_checked_mail('"+_getId+"')>";
                            _email += " Delete";
                            _email += "</a>";
                            _email += "</li>";
                            $('.list-email-checked').append(_email); 
                            $('.list-user-email .mail_'+_getId+' span').addClass('checked');                          
                        }                                                    
                    }else{
                      $('.list-email-checked li').remove();
                      $('.list-user-email li div span').removeClass('checked'); 
                    }                
            })                                                
    });     
</script>
<?php         
echo $this->Form->hidden('task', array('id' => 'task', 'value' => ''));
echo $this->Form->end();
?>
